<?php
/**
 * 文章管理
 * $Id: manage_article.php 202 2010-11-15 12:36:01Z bwanglei@gmail.com $
 */

require_once './globals.php';
require_once AW_ROOT.'/model/class.blog.php';
require_once AW_ROOT.'/model/class.tag.php';

$aw_blog = new awBlog();
$awTag = new awTag();
$blog_title = '管理文章 - '.$blogname;

$bookmark = isset($_GET['b']) ? $_GET['b'] : '';

if ($_SERVER['REQUEST_METHOD']=='POST' && $action=='del') {
	$id_article = intval($_POST['id_article']);
	$aw_blog->deleteLog($id_article);
	//更新缓存
	$CACHE->updateCache('tags');
	$CACHE->updateCache('comment');
	$CACHE->updateCache('record');
	$CACHE->updateCache('sta');
	header('Location: '.$_SERVER['REQUEST_URI']);exit;
}

if (!isset($_GET['type']) || $_GET['type'] == 'draft') {
	$sql_add = ' `type`=\'draft\'';
} else if ($_GET['type'] == 'page') {
	$sql_add = ' `type`=\'page\'';
} else if ($_GET['type'] == 'article') {
	$sql_add = ' `type`=\'article\'';
}
$a_result = $aw_blog->getLogsForHome($sql_add,$bookmark,$index_newlognum);
$articles = $a_result[0];
$pre_bookmark = $a_result[1];
$next_bookmark = $a_result[2];
//添加每个贴子的评论数量到数组中
logs_add_comnum($articles);
add_tag_articles($articles);

include_once TEMPLATE_PATH.'/header.php';
include_once TEMPLATE_PATH.'/manage_article.php';
include_once TEMPLATE_PATH.'/sidebar.php';
include_once TEMPLATE_PATH.'/footer.php';
